﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TimeAxis.Models;
using TimeAxis.Interfaces;

namespace TimeAxis.Impls
{
    public class ImplDocCategory : IDocCategory
    {
        private DavidDB.ADO.DBManager dbmanager = null;


        #region 返回接口实现

        private ImplDocCategory(DavidDB.ADO.DBManager db) { this.dbmanager = db; }

        public static IDocCategory GetInstance(DavidDB.ADO.DBManager db)
        {
            IDocCategory instance = new ImplDocCategory(db);
            return instance;
        }
        #endregion
        #region 默认接口实现

        /// <summary>
        /// 得到所有 问题分类关系在大项目中尽量少用，这个方法返回的数据量过于庞大
        /// </summary>
        /// <returns>所有问题分类关系</returns>
        public List<DocCategory> GetList()
        {
            DocCategory field = new DocCategory();
            var objs = dbmanager.GetList(field);
            List<DocCategory> fields = new List<DocCategory>();
            foreach (DocCategory _field in objs)
            {
                fields.Add(_field);
            }
            return fields;
        }

        /// <summary>
        /// 分页显示问题分类关系
        /// </summary>
        /// <param name="PageSize">每页记录数</param>
        /// <param name="NowPage">当前页</param>
        /// <param name="PageCount">总共多少页</param>
        /// <param name="recordCount">总记录数</param>
        /// <returns>查询到的记录</returns>
        public List<DocCategory> GetListByPage(int PageSize, int NowPage, out int PageCount, out int recordCount)
        {
            DocCategory field = new DocCategory();
            var objs = dbmanager.GetListByPage(PageSize, NowPage, out PageCount, out recordCount, field);
            List<DocCategory> fields = new List<DocCategory>();
            foreach (DocCategory _field in objs)
            {
                fields.Add(_field);
            }
            return fields;
        }

        /// <summary>
        /// 分页模糊查询问题分类关系
        /// </summary>
        /// <param name="doccategory">对象实体</param>
        /// <param name="PageSize">每页记录数</param>
        /// <param name="NowPage">当前页</param>
        /// <param name="PageCount">总共多少页</param>
        /// <param name="recordCount">总记录数</param>
        /// <returns>查询到的记录</returns>
        public List<DocCategory> GetListByPageLikeKey(DocCategory doccategory, int PageSize, int NowPage, out int PageCount, out int recordCount)
        {
            var objs = dbmanager.GetListByPageLikeKey(PageSize, NowPage, doccategory, out PageCount, out recordCount);
            List<DocCategory> fields = new List<DocCategory>();
            foreach (DocCategory _field in objs)
            {
                fields.Add(_field);
            }
            return fields;
        }

        /// <summary>
        /// 分页查询问题分类关系
        /// </summary>
        /// <param name="doccategory">对象实体</param>
        /// <param name="PageSize">每页记录数</param>
        /// <param name="NowPage">当前页</param>
        /// <param name="PageCount">总共多少页</param>
        /// <param name="recordCount">总记录数</param>
        /// <returns>查询到的记录</returns>
        public List<DocCategory> GetListByPageAndKeys(DocCategory doccategory, int PageSize, int NowPage, out int PageCount, out int recordCount)
        {
            var objs = dbmanager.GetListByPageAndKeys(PageSize, NowPage, doccategory, out PageCount, out recordCount);
            List<DocCategory> fields = new List<DocCategory>();
            foreach (DocCategory _field in objs)
            {
                fields.Add(_field);
            }
            return fields;
        }

        /// <summary>
        /// 得到一个问题分类关系
        /// </summary>
        /// <param name="id">对象实体</param>
        /// <returns>对象</returns>
        public DocCategory GetModel(int id)
        {
            DocCategory field = new DocCategory();
            field.Id = id;
            return dbmanager.GetModel(field) as DocCategory;
        }

        /// <summary>
        /// 保存一个问题分类关系
        /// </summary>
        /// <param name="doccategory">对象实体</param>
        /// <returns>编号</returns>
        public int Insert(DocCategory doccategory)
        {
            return dbmanager.Insert(doccategory);
        }

        /// <summary>
        /// 按关键字查询头几条
        /// </summary>
        /// <param name="count">数量</param>
        /// <returns>问题分类关系的列表</returns>
        public List<DocCategory> GetTopList(int count)
        {
            DocCategory field = new DocCategory();
            var objs = dbmanager.GetTopList(count, field);
            List<DocCategory> fields = new List<DocCategory>();
            foreach (DocCategory _field in objs)
            {
                fields.Add(_field);
            }
            return fields;
        }

        /// <summary>
        /// 判断问题分类关系是否唯一存在
        /// </summary>
        /// <param name="doccategory">对象实体</param>
        /// <returns>是否存在</returns>
        public bool IsExist(DocCategory doccategory)
        {
            return dbmanager.IsExist(doccategory);
        }

        /// <summary>
        /// 判断问题分类关系是否存在
        /// </summary>
        /// <param name="doccategory">对象实体</param>
        /// <returns>是否存在</returns>
        public bool IsJustExist(DocCategory doccategory)
        {
            return dbmanager.IsJustExist(doccategory);
        }

        /// <summary>
        /// 得到关键字等于。。。的所有问题分类关系
        /// </summary>
        /// <param name="doccategory">对象实体</param>
        /// <returns>问题分类关系的List</returns>
        public List<DocCategory> GetSomeObject(DocCategory doccategory)
        {
            var objs = dbmanager.GetSomeObject(doccategory);
            List<DocCategory> fields = new List<DocCategory>();
            foreach (DocCategory _field in objs)
            {
                fields.Add(_field);
            }
            return fields;
        }

        /// <summary>
        /// 编辑一个问题分类关系
        /// </summary>
        /// <param name="obj">对象实体</param>
        public void Edit(DocCategory doccategory)
        {
            dbmanager.Edit(doccategory);
        }

        /// <summary>
        /// 删除一个问题分类关系
        /// </summary>
        /// <param name="doccategory">对象实体</param>
        public void Delete(DocCategory doccategory)
        {
            dbmanager.Delete(doccategory);
        }

        /// <summary>
        /// 删除所有问题分类关系
        /// </summary>
        public void DeleteAll()
        {
            DocCategory field = new DocCategory();
            dbmanager.DeleteAll(field);
        }

        /// <summary>
        /// 按关键字删除
        /// </summary>
        /// <param name="doccategory">对象实体</param>
        public void DeleteColumByKey_Value(DocCategory doccategory)
        {
            dbmanager.DeleteColumByKey_Value(doccategory);
        }

        #endregion

        #region 自定义接口实现


        #endregion

    }
}
